import { ApiGitLogin } from "../api/index";

//10、正确配置第三方（码云）信息 113:10秒
const gitee = {
    client_id: '37ff5eab7bcc01dbb5e4cdcbeacf9cc564f84b5febe0169c03d2be686f80db77',
    client_secret: '78fb22911599e27b5a4a8e20ba6ee488d78c7df651b7c30609ba8cb68dca3894',
    redirect_uri: 'http://localhost:8080/login'
}
export const getCode = () => {
    let url = `https://gitee.com/oauth/authorize?client_id=${gitee.client_id}&redirect_uri=${gitee.redirect_uri}&response_type=code`;
    window.location.href = url;
}
export const gitLogin = () => {
    // 11、前端正确获取用来代替密码登录的短期令牌 
    let code = window.location.search.split('=')[1]
    ApiGitLogin({ code }).then(res => {
        if (res.data.code == 200) {
            window.location.href = 'http://localhost:8080'
            localStorage.setItem('token', res.data.token);
            this.$message({
                message: res.data.msg,
                type: 'success'
            });
        }
    })
}